#!/bin/sh
case "$1" in
   version)
      echo "1.20.00"
      ;;
   *)
      # refuse to update if the md5 fails
      if ! echo "101b51d5dc51e8f2b9c8e2dab66fbe95 *hs2tchrootfs.ext2" |md5sum -c; then
         echo "MD5 failed"
         exit 1
      fi
      
#     runing the following block in the background to kick the watchdog so that the "cp" command works fine
      {
         while :
            do
               echo 1 >> /dev/watchdog
               echo "-----> Kicking Watchdog"
               sleep 5
            done
      } &

#     mount -r rootfs.ext2 /mnt
      mount -r hs2tchrootfs.ext2 /mnt
      cd /mnt
      usr/bin/kobs-ng boot/imx28_ivt_linux.sb
#     mount boot/rootfs.ext2 mnt
      mount boot/hs2tchrootfs.ext2 mnt
      for i in `ls -1r /etc/init.d/S??*` ;do $i stop; done
      killall syslogd klogd
      # copy everything
      cp -R /mnt/mnt/* /
      reboot
      ;;
esac

exit 0

